01. Introduction

Kotlin SM A01 Intro

Introduction

MotionLayout is a library that lets you add rich motion into your Android app. It's based upon ConstraintLayout and lets you animate anything that you can build using ConstraintLayout.

You can use MotionLayout to animate the location, size, visibility, alpha, color, elevation, rotation, and other attributes of multiple views at the same time. Using declarative XML you can create coordinated animations involving multiple views that are difficult to achieve in code.

MotionLayout animations extend many of the same concepts as Keyframe animations with Constraint Layout to allow you to finely customize the animation.

In this codelab, you will learn the basics of MotionLayout and how to use it to build rich animations in your app.

Why do we animate?

Animations are a great way to enhance an app experience. You can use animations to:

  • Show changes - animating between states lets the user naturally track changes in your UI.
  • Draw attention - use animations to draw attention to important UI elements.
  • Build beautiful designs - effective motion in design makes apps look polished.

What you’ll learn

  • Defining an animation with ConstraintSets and MotionLayout
  • Animating based on drag events
  • Changing the animation with KeyPosition
  • Changing attributes with KeyAttribute
  • Running animations with code
  • Animating collapsible headers with MotionLayout

Learn more about Constraint Layout

To use MotionLayout you need to be familiar with Constraint Layout. Read through the *Constraint Layout codelab *
to learn more about constraint layout.